#!/bin/bash
# Copyright (c) 2020 Presto Labs Pte. Ltd.
# Author: donggu

set -e

source ci/buildkite/pipeline-pr/scripts/git-rev.sh

echo '# ---------------------------------------------------------------------------- #'
echo "#    Diff between $BUILDKITE_PULL_REQUEST_BASE_BRANCH($BASE) and HEAD($HEAD)   #"
echo '# ---------------------------------------------------------------------------- #'

git diff origin/$BUILDKITE_PULL_REQUEST_BASE_BRANCH...HEAD --name-only --diff-filter=ACM \
| rg -v "external|third_party|experimental" \
| rg "(\.cc|\.h)$" \
|| true

echo '# ---------------------------------------------------------------------------- #'
echo '#                                    Cpplint                                   #'
echo '# ---------------------------------------------------------------------------- #'

git diff origin/$BUILDKITE_PULL_REQUEST_BASE_BRANCH...HEAD --name-only --diff-filter=ACM \
| rg -v "external|third_party|experimental" \
| rg "(\.cc|\.h)$" \
| parallel -k --max-args 1 cpplint --quiet --linelength=100 --filter=-build/c++11,-build/namespaces,-build/include_order,-runtime/string,-whitespace/braces 1>/dev/null
